﻿using CommunityToolkitMvvmDemo.ViewModels;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;

namespace CommunityToolkitMvvmDemo.ValidationRules
{
    public class GroupValueValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            BindingGroup bindingGroup = (BindingGroup)value;
            var d = (HandyControlViewModel)bindingGroup.Items[0];

            if (d.Min >= d.Max)
            {
                return new ValidationResult(false, "错误，最小值必须小于最大值");
            }
            return new ValidationResult(true, null);
        }
    }

}
